<?php
class Session_model extends CI_Model{
	
	function __construct() {
        parent::__construct();
    }
    
    public function start_session($customer_id){
    	$date = new Date();
    	$sql = "INSERT session (session_customer_id, session_date) VALUES({$customer_id}, {$date})";
    	$query = $this->db->query($sql);
    	if ($query){
    		return TRUE;
    	}else{
    		return FALSE;
    	}
    }
    
    public function update_session($customer_id, $viewed_product){
    	$sql = "";
    	$query = $this->db->query($sql);
    	if ($query->num_rows > 0){
    		return $query->result_array();
    	}else{
    		return FALSE;
    	}
    }
    
    public function get_cart($user_id){
    	$user_id = intval($user_id);
    	$sql = "SELECT session_cart as cart FROM `session` 
    			WHERE session_id = (SELECT MAX(session_id) as session_id FROM session 
    								WHERE session_customer_id = {$user_id})";
    	$query = $this->db->query($sql);
    	if ($query->num_rows > 0){
    		return $query->result_array();
    	}else{
    		return FALSE;
    	}
    }
}

/* End of file session_model.php */
/* Location: ./application/models/session_model.php */